<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./../jquery-1.12.4.js"></script>
    <script>
        $(function () {
            $('button').click(function () {
                var $h6 = $('<h6>我是h6</h6>');
                // $('h1').replaceWith($h6)
                $h6.replaceAll($('h1'))
            })
        })
    </script>
</head>

<body>
    <button>替换节点</button>
    <h1>我是标题1</h1>
    <h1>我是标题1</h1>
    <p>我是段落</p>
</body>

</html>